<?php
/**
 *  NevuxBB - Free Forum Software
 *  Copyright (C) 2008, 2010 NevuxBB (No one specific author)*  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Registration System
 * File: register.php
 * Purpose: Allowing the user to make an account
 * Todo: Add extra spam control filtering
 *
 */
require('system/files/global.php');

// start the initalisation of the main page (forum page)
$core_template_system->setvar(array('page_title' => 'Registration',
									'registration_js' => true));

// show the header loaded
$core_template_system->pparse();

// build breadcrumb
$core_template_system->setvar('breadcrumb',
				$core_nav_system->generateNav(array('settings' => array('level_down' => false,
																		'main_class' => 'menu'),
													'information' => array('home' => array('data' => array(1 => 'Home',
																										   2 => 1)),
																		   'register' => array('data' => array(1 => 'Registration',
																											   2 => 5))))));

// are we currently logged in?
if(CoreUserSystem::isLoggedIn()) {
	// user is already logged in
	// language file
	$core_lang_system->reset();
	$core_lang_system->add_file('login');

	// error
	$core_template_system->setvar(array('error_message' => $core_lang_system->get_var('ALREADY_LOGGED_IN', 3),
										'error', $core_lang_system->get_var('ERROR', 4),
										'back_url', 'index.php'));
	
	// render the page
	$core_template_system->newTemplate(BASE_PATH . '/templates/' . ForumSettings::getCurrentTemplate() . '/error.html');
	$core_template_system->pparse();
} else {
	if(isset($_POST['rq'])) {
		// wants to send a request to process
		
	} else {
		// have we accepted the ToS?
		if(isset($_POST['nev_f_agree'])) {
			// we haven't got a request, show the form
			$core_template_system->setvar('produce_form', true);
		} else {
			// show the ToS
			$core_template_system->setvar('tos_form', true);
		}
	}
	
	// render the page
	$core_template_system->newTemplate(BASE_PATH . '/templates/' . ForumSettings::getCurrentTemplate() . '/register.html');
	$core_template_system->pparse();
}

// footer
require('system/files/footer.php');
?>